package com.action.newbroad;

import java.util.ArrayList;
import java.util.List;

import com.db.newbroad.*;

public class ContentAction {
	private int no;
	private int page;
	private NewbroadVO vo = new NewbroadVO();
	private List<Newbroad_replyVO> nblist = new ArrayList<Newbroad_replyVO>();
	private String content;
	private String id;
	private NewbroadDAO newbroad;
	private int rno;

	public NewbroadDAO getNewbroad() {
		return newbroad;
	}

	public void setNewbroad(NewbroadDAO newbroad) {
		this.newbroad = newbroad;
	}

	public void setRno(int rno) {
		this.rno = rno;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public NewbroadVO getVo() {
		return vo;
	}

	public List<Newbroad_replyVO> getNblist() {
		return nblist;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String execute() throws Exception {

		nblist = newbroad.newbroad_replyAllData(no);

		System.out.println("content : " + no);
		newbroad.newbroadIncreament(no);
		vo = newbroad.newbroadContentData(no);
		System.out.println(vo.toString());
		return "success";
	}

	public String reply_insert() throws Exception {

		Newbroad_replyVO rvo = new Newbroad_replyVO();
		rvo.setGroupno(no);
		rvo.setId(id);
		rvo.setContent(content);

		newbroad.newbroad_replyInsert(rvo);
		nblist = newbroad.newbroad_replyAllData(no);

		newbroad.newbroadIncreament(no);
		vo = newbroad.newbroadContentData(no);

		return "success";
	}

	public String reply_delete() throws Exception {

		newbroad.newbroad_replyDelete(rno);

		nblist = newbroad.newbroad_replyAllData(no);

		newbroad.newbroadIncreament(no);
		vo = newbroad.newbroadContentData(no);

		return "success";
	}

	public String reply_update() throws Exception {

		Newbroad_replyVO rvo = new Newbroad_replyVO();

		rvo.setContent(content);
		rvo.setNo(rno);
		System.out.println("1111111111111111111111111");
		newbroad.newbroad_replyUpdate(rvo);

		nblist = newbroad.newbroad_replyAllData(no);

		newbroad.newbroadIncreament(no);
		vo = newbroad.newbroadContentData(no);

		return "success";
	}

}
